Support mounting /sysroot (and /boot) read-only
authorColin Walters <walters@verbum.org>
Wed, 3 Oct 2018 14:57:19 +0000 (14:57 +0000)
committerColin Walters <walters@verbum.org>
Wed, 11 Dec 2019 15:33:57 +0000 (15:33 +0000)
commit5af403be0cc64df50ad21cef05f3268ead256d6d
tree2b6157627dbf92d4556c4b7910a878326081fa13
parent20daf9688006f17e11af7692d2e43292b36df71f
Support mounting /sysroot (and /boot) read-only

We want to support extending the read-only state to cover `/sysroot`
and `/boot`, since conceptually all of the data there should only
be written via libostree.  Or at least for `/boot` should *mostly*
just be written by ostree.

This change needs to be opt-in though to avoid breaking anyone.

Add a `sysroot/readonly` key to the repository config which instructs
`ostree-remount.service` to ensure `/sysroot` is read-only.  This
requires a bit of a dance because `/sysroot` is actually the same
filesystem as `/`; so we make `/etc` a writable bind mount in this case.

We also need to handle `/var` in the "OSTree default" case of a bind
mount; the systemd generator now looks at the writability state of
`/sysroot` and uses that to determine whether it should have the
`var.mount` unit happen before or after `ostree-remount.service.`

Also add an API to instruct the libostree shared library
that the caller has created a new mount namespace.  This way
we can freely remount read-write.

This approach extends upon in a much better way previous work
we did to support remounting `/boot` read-write.

Closes: https://github.com/ostreedev/ostree/issues/1265
12 files changed:
Makefile-switchroot.am
apidoc/ostree-sections.txt
src/boot/ostree-remount.service
src/libostree/libostree-devel.sym
src/libostree/ostree-impl-system-generator.c
src/libostree/ostree-sysroot-cleanup.c
src/libostree/ostree-sysroot-deploy.c
src/libostree/ostree-sysroot-private.h
src/libostree/ostree-sysroot.c
src/libostree/ostree-sysroot.h
src/ostree/ot-main.c
src/switchroot/ostree-remount.c